# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rbs
_gemname=rbs
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=3.3.2
pkgrel=0
pkgdesc="Type Signature for Ruby"
url="https://github.com/ruby/rbs"
arch="all"
license="BSD-2-Clause AND Ruby"
depends="ruby ruby-bundler"
checkdepends="ruby-rake ruby-test-unit"
makedepends="ruby-dev ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/rbs/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # FIXME: require gems that are not packaged yet

build() {
	gem build $_gemname.gemspec

	gem install \
		--local \
		--install-dir dist \
		--bindir dist/bin \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname
}

check() {
	GEM_PATH='dist' rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r doc extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
ef0ac2bf65cebd12596c2e7cecd5eeb41abf169f18cdd8cfe056195150ebcb2544b2c65cbfdd63f6e9f2af3e95d5a312aa7db230b2bb03d44f995cf0522ae754  rbs-3.3.2.tar.gz
39f59efc8ed4af86314e630c19cbefdf5df740c3baf8e51e184a58f8a42df7fb5c47d8f3563e97fff1f41d38d3d4d80ba665378ac82b24983a9aa49d4f7e11e4  gemspec.patch
"
